package cn.beyondPlatform.wei.service.BackendUser.impl;

import cn.beyondPlatform.wei.dao.backend.BackendDao;
import cn.beyondPlatform.wei.exception.LoginException;
import cn.beyondPlatform.wei.pojo.BackendUser;
import cn.beyondPlatform.wei.service.BackendUser.BackendUserService;
import cn.beyondPlatform.wei.utils.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class BackendUserServiceImpl implements BackendUserService {
    @Autowired
    private BackendDao backendDao;

    @Override
    public BackendUser devLogin(String userCode, String userPassword) throws LoginException {
        BackendUser backendUser = backendDao.backLogin(userCode, userPassword);
        System.out.print(333);
        if (backendUser == null) {
            throw new LoginException("用戶不存在");
        }
        if (!userPassword.equals(backendUser.getUserPassword())) {
            throw new LoginException("密码不正确");
        }
        return backendUser;
    }
}
